# SPDX-FileCopyrightText: 2018 CitruS Emulator Project
# SPDX-License-Identifier: GPL-2.0-or-later

string(TOLOWER "${CMAKE_SYSTEM_PROCESSOR}" SYSTEM_PROCESSOR_LOWER)
if (SYSTEM_PROCESSOR_LOWER MATCHES "(aarch64|arm64)")
enable_language(ASM)
set(BOOST_CONTEXT_SRC
    jump_arm64_aapcs_elf_gas.S
    make_arm64_aapcs_elf_gas.S
)
elseif (SYSTEM_PROCESSOR_LOWER MATCHES "(x86_64|amd64)")
if (MSVC)
enable_language(ASM_MASM)
set(BOOST_CONTEXT_SRC
    jump_x86_64_ms_pe_masm.asm
    make_x86_64_ms_pe_masm.asm
)
else()
enable_language(ASM)
set(BOOST_CONTEXT_SRC
    jump_x86_64_sysv_elf_gas.S
    make_x86_64_sysv_elf_gas.S
)
endif()
else()
    message(FATAL_ERROR "Unsupported Architecture ${CMAKE_SYSTEM_PROCESSOR} - FAILED")
endif()

add_library(context STATIC ${BOOST_CONTEXT_SRC})
set_target_properties(context PROPERTIES COMPILE_OPTIONS "")